from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
from domains.Assistant import Assistant
from domains.QuestionParser import QuestionParser
from settings import IS_HEADLESS
from domains.ConfigParser import ConfigParser

if __name__ == '__main__':
    options = Options()
    # 去掉自动化测试的提示
    options.add_experimental_option('useAutomationExtension', False)
    options.add_experimental_option("excludeSwitches", ['enable-automation'])
    # 取消保存密码提示框
    prefs = {"credentials_enable_service": False,
             "profile.password_manager_enabled": False
             }
    options.add_experimental_option("prefs", prefs)
    # 设置无头模式
    if IS_HEADLESS:
        options.add_argument('--headless')
    # 获取driver对象
    driver = webdriver.Chrome(options)

    # 获取解析器对象
    qp = QuestionParser(r'D:\Code\Python_code\LryAssistant\temp\2.3quiz：答题回顾(1).html')

    # 获取配置文件解析器
    cp = ConfigParser(r"D:\Code\Python_code\LryAssistant\configs.json")

    # 获取Assistant对象
    # print(qp.desc2que.keys())
    ass = Assistant(driver, cp, qp)
    # 执行工作方法
    ass.run()

    time.sleep(10)
